<template>
  <div>
      <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="did" label="医生did" width="100" v-if="show">
      </el-table-column>
      <el-table-column prop="depname" label="所属团队" width="100">
      </el-table-column>
      <el-table-column prop="dname" label="医生姓名" width="80">
      </el-table-column>
      <el-table-column prop="dtel" label="联系电话" width="100">
      </el-table-column>
      <el-table-column prop="dage" label="年龄" width="60">
      </el-table-column>
      <el-table-column prop="dsex" label="性别" width="60">
      </el-table-column>
      <el-table-column prop="dimage" label="照片" width="100">
      </el-table-column>
      <el-table-column prop="dtext" label="医生简介" width="100">
      </el-table-column>
      <el-table-column prop="dCertificate" label="医生资格证书" width="100">
      </el-table-column>
      <el-table-column prop="title" label="职称" width="100">
      </el-table-column>
      <el-table-column prop="education" label="学历" width="100">
      </el-table-column>
      <el-table-column prop="school" label="毕业院校" width="100">
      </el-table-column>
      <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <el-button @click="goSign(scope.row)">签约</el-button>
        </template >
      </el-table-column>
    </el-table>
      <div>
    <!-- 提醒模态框开始 -->
    <el-dialog title="已购买同类型的套餐服务，是否再续约一年？" :visible.sync="dialogFormVisible">
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="continueSign">确认续约</el-button>
        <el-button @click="dialogFormVisible = false">取消</el-button>
      </div>
    </el-dialog>
    <!-- 提醒模态框结束 -->
      
  </div>
  </div>
</template>
<script>
export default {
  mounted() {
    this.updateTable();
  },
  data() {
    return {
      dialogFormVisible: false,
      show:false,
      tableData: [],
      options:[],
      formLabelWidth: "120px",
      form:{
        oid:"",
        did:"",
        pid:"",
        otid:"",
        startTime:"",
        endTime:"",
        ostate:"服务中",
      }
    };
  },
  methods: {
      updateUI(row) {
      this.dialogFormVisible = true;
    },
    updateTable() {
          let dhospital=JSON.parse(sessionStorage.getItem("dhospital"));
          let depname=JSON.parse(sessionStorage.getItem("depname"));
          this.$axios.post("patient-serv/patientinfo/selSignDoc/"+dhospital+"/"+depname).then((response) => {
          let r = response.data;
          this.tableData=r.data;
        });
    },
     goSign(e) {
      this.form.otid=JSON.parse(sessionStorage.getItem("otid"));
      this.form.pid=JSON.parse(sessionStorage.getItem("pat")).pid;
      this.form.did=e.did;
      let info = JSON.stringify(e.did);
      sessionStorage.setItem("did", info);
      this.$axios.post("patient-serv/patientinfo/goSign",this.form).then((response) => {
        if(response.data.code==200){
          this.$message.success("签约成功");
        }else{
          this.updateUI();
        }
      });
    },
    continueSign(e) {
      this.form.otid=JSON.parse(sessionStorage.getItem("otid"));
      this.form.pid=JSON.parse(sessionStorage.getItem("pat")).pid;
      this.form.did=JSON.parse(sessionStorage.getItem("did"));
      this.$axios.post("patient-serv/patientinfo/continueSign",this.form).then((response) => {
          this.$message.success("续约成功");
          this.dialogFormVisible = false;
      });
    },
  }
};
</script>

<style>

</style>